<template>
<view>
<view v-if="feedback_type!=1">
    <view class="banner" v-if="feedback_type!=1">
        <view class="banner_top">
            <image class="banner_top_img" src="/static/pages/image/duigou_icn.png"></image>
            请选择举报的理由</view>
        <view class="banner_bottom">本平台会坚决落实非法、虚假、色情等信息，你的举报我们会认真查实并根据平台协议进行落实！</view>
    </view>
    <view class="nav" v-if="feedback_type!=1"></view>
    <view class="modle_nav" v-if="feedback_type!=1">
        <view class="modle_nav_biaoji"></view>
        <text>车辆信息</text>
    </view>
    <form @submit="formSubmit">
        <radio-group @change="radioChange" v-if="feedback_type!=1">
            <label v-for="(item, index) in items" :key="index">
                <view class="modle_nav">
                    <radio :checked="item.checked" color="#0AC2AE" :value="index"></radio>
                    <text>{{item.name}}</text>
                </view>
            </label>
        </radio-group>
        <view class="nav"></view>
        <view class="modle_nav">
            <view class="modle_nav_biaoji"></view>
            <text>{{feedback_type==1?'留言内容':'举报理由'}}</text>
        </view>
        <textarea class="text_area" name="content" :placeholder="(feedback_type==1?'留言内容':'举报理由') + '（不少于20字）'" placeholderStyle="color:9295A8"></textarea>
        <view class="btn_view">
            <button class="tijiao_btn tijiao_btn_active" form-type="submit">提交</button>
        </view>
    </form>
</view>
<view v-if="feedback_type==1">
    <view v-for="(item, index) in content" :key="index" class="modle" v-if="content.length>0">
        <view class="modle_top">
            <image class="modle_top_img" :src="item.head_image"></image>
            <view class="modle_top_text_index">{{item.nickname?item.nickname:'匿名留言'}}</view>
            <view class="modle_top_text_second">{{item.time}}</view>
        </view>
        <view class="modle_text">{{item.content}}</view>
    </view>
    <view @tap="more" class="more" v-if="more_status&&content.length>3">查看更多
        <image class="more_img" src="/static/pages/image/lvsejtxx_btn.png"></image>
    </view>
    <view class="nav"></view>
    <form @submit="formSubmit">
        <view class="modle_nav">
            <view class="modle_nav_biaoji"></view>
            <text>商家留言</text>
        </view>
        <textarea class="text_area" name="content" :placeholder="(feedback_type==1?'留言内容':'举报理由') + '（不少于20字）'" placeholderStyle="color:9295A8"></textarea>
        <view class="btn_view">
            <button class="tijiao_btn tijiao_btn_active" form-type="submit">提交</button>
        </view>
    </form>
</view>
<!--<import src="/pages/alert/index.wxml"></import>-->
<block data-type="template" data-is="alert" data-attr="isShow:isShow">
    <view class="wx_dialog_container" :hidden="!isShow">
        <view class="wx-alert-mask"></view>
        <view class="wx-alert-dialog">
            <view class="wx-alert-dialog-title">尊敬的用户</view>
            <view class="wx-alert-dialog-content">尚未获取到您的用户信息，较多功能无法体验，请允许获取用户信息</view>
            <view class="wx-alert-dialog-footer">
                <button @tap="hideDialog" class="wx-alert-dialog-btn">拒绝</button>
                <button @getuserinfo="updateUserInfo" class="wx-alert-dialog-btn" open-type="getUserInfo">允许</button>
            </view>
        </view>
    </view>
</block>
</view>
</template>

<script>
function _toConsumableArray(t) {
  if (Array.isArray(t)) {
    for (var a = 0, e = Array(t.length); a < t.length; a++) e[a] = t[a];

    return e;
  }

  return Array.from(t);
}
var app = getApp();

export default {
  data() {
    return {
      car_uid: 0,
      value: "",
      feedback_type: 1,
      isShow: !1,
      more_status: !0,
      items: [{
        name: "虚假信息",
        checked: "true"
      }, {
        name: "广告"
      }, {
        name: "其他"
      }],
      leftid: 1,
      content: [],
      car_id: ""
    };
  },

  components: {},
  props: {},
  onLoad: function (t) {
    console.log(t), t.form_type && "undefined" != t.form_type && this.setData({
      feedback_type: t.form_type,
      car_id: t.car_id,
      car_uid: t.car_uid
    }), wx.getUserInfo({
      success: function (t) {
        console.log(t);
      },
      fail: function (t) {
        console.log(t);
      }
    }), wx.setNavigationBarTitle({
      title: 1 == this.feedback_type ? "留言商家" : "举报商家"
    }), this.stayFun();
  },
  onShow: function () {
    var a = this;
    app.globalData.util.getUserInfo(function (t) {
      wx.getStorageSync("uid") && t.memberInfo || a.setData({
        isShow: !0
      });
    });
  },
  methods: {
    stayFun: function () {
      var e = this;
      app.globalData.util.request({
        url: "entry/wxapp/Api",
        data: {
          m: "monai_market",
          r: "home.index.stay",
          car_id: this.car_id,
          leftid: this.leftid++
        },
        cachetime: "0",
        success: function (t) {
          var a;
          (console.log(t), 0 < t.data.data.length) ? (console.log(t), (a = e.content).push.apply(a, _toConsumableArray(t.data.data)), e.setData({
            content: e.content
          })) : e.setData({
            more_status: !1
          });
        }
      });
    },
    more: function () {
      this.stayFun();
    },
    formSubmit: function (t) {
      console.log(wx.getStorageSync("uid"));
      var a = t.detail.value,
          e = "";
      1 != this.feedback_type && (e = "[车辆信息]:" + this.value), a.content ? app.globalData.util.request({
        url: "entry/wxapp/Api",
        data: {
          m: "monai_market",
          r: "home.index.word",
          content: a.content,
          car_uid: this.car_uid,
          car_info: e,
          feedback_type: this.feedback_type,
          uid: wx.getStorageSync("uid"),
          car_id: this.car_id
        },
        cachetime: "0",
        success: function (t) {
          console.log(t), wx.showModal({
            title: "提示",
            content: "提交信息成功",
            showCancel: !1,
            success: function (t) {
              wx.navigateBack({});
            }
          });
        }
      }) : wx.showModal({
        title: "提示",
        content: "内容不能为空！",
        showCancel: !1,
        success: function (t) {}
      });
    },
    radioChange: function (t) {
      0 == t.detail.value ? this.value = "虚假信息" : 1 == t.detail.value ? this.value = "广告" : 2 == t.detail.value && (this.value = "其他");
    },
    hideDialog: function () {
      this.setData({
        isShow: !this.isShow
      });
    },
    updateUserInfo: function (t) {
      var a = this;
      app.globalData.util.getUserInfo(function (t) {
        wx.setStorageSync("uid", t.memberInfo.uid), a.hideDialog();
      }, t.detail);
    }
  }
};
</script>
<style>
@import "./jubao.css";
</style>